package com.sprucetec.live.service.impl;

import com.sprucetec.live.entity.LiveOnlineUser;
import com.sprucetec.live.mapper.LiveOnlineUserMapper;
import com.sprucetec.live.service.LiveOnlineUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @ClassName LiveOnlineUserServiceImpl
 * @Description:
 * @Author Kenny
 * @Date 2020/4/14
 **/
@Slf4j
@Service("liveOnlineUserService")
public class LiveOnlineUserServiceImpl implements LiveOnlineUserService {
    @Autowired
    private LiveOnlineUserMapper liveOnlineUserMapper;

    @Override
    public void batchInsert(List<LiveOnlineUser> liveOnlineUserList) {
        liveOnlineUserMapper.batchInsert(liveOnlineUserList);
    }


    @Override
    public List<LiveOnlineUser> getOnlineUserByLiveNo(String liveNo) {
        Example example = new Example(LiveOnlineUser.class);
        example.createCriteria().andEqualTo("relateVideoNo", liveNo);
        return liveOnlineUserMapper.selectByExample(example);
    }

    @Override
    public void clearUserByCondition(Example example) {
        liveOnlineUserMapper.deleteByExample(example);
    }
}
